 (August 1998).iso/images/contents.GIF)
 (August 1998).iso/images/ful.GIF)
 (August 1998).iso/images/trial.GIF)
 (August 1998).iso/images/news.GIF)
 (August 1998).iso/images/online.GIF)
 (August 1998).iso/images/ho.gif)
 (August 1998).iso/images/ess.GIF)
 (August 1998).iso/images/tact.GIF)
 (August 1998).iso/images/help.GIF)
|
Visual Basic Workshop
Crystal Reports 5, given away free on issue 140's SuperCD, provides an easy way to
build database reporting into your programs. Dermot Hogan continues his tutorial from last month.
In the last issue I looked at using the Crystal Reports ActiveX control as a super-simple
way of creating reports from a Visual Basic program. Now we go further into programming
Crystal Reports in Visual Basic.
The key to using Crystal Reports from a program is the Report Engine, the central powerhouse
of Crystal Reports itself. ItÆs separate from the graphical Report Designer (which you still
have to use to specify the report in the first place), but using the Report Engine API you
can control the appearance and output of the reports to a considerable degree.
The example project shows four simple ways of generating a report, each using a bit more of
the Report Engine API. If youÆve got Crystal Reports installed, you can try this out by
opening project1.vbp
To Copy Project1.vbp to your disk.
This project only works with Visual Basic
5 or 6, or Visual Basic 5 Control Creation Edition. If you don't have any of these, VB5CCE has been on many recent SuperCDs.
VB5CCE does not set up file associations so if you're using that, you will need to use
its File, Open Project dialog to load PROJECT1.VBP rather than clicking the link on this
page. Also, you need to copy the file TEST1.RPT into your Crystal Reports directory. The
program expects to find TEST1.RPT in the default location of C:\CRW.
 (August 1998).iso/images/DEMO.GIF)
Three of the four buttons demonstrate creating a Crystal Report while the fourth closes a
report preview window. The first, Print, just prints out a test report to the default Windows
printer. But be careful û the report is 49 pages in length! You can cancel it by clicking on
the Cancel Printing button in the Printing Records dialog box that Crystal Reports creates as
itÆs sending output to the printer.
The second button, Preview, shows the same report sent to a preview window. This is done
using the simplest Report Engine API, PEPrintReport. While you can use this to preview a
report before printing it, itÆs fairly limited in scope. The next button, Custom, shows the
same report but displayed using more of the Report Engine API to get greater flexibility.
This is demonstrated with the last button, Cancel, which uses the API to close the preview
window and cancel the print job. The button works for this window only û not those created
by the other buttons.
|
|
|